<template>
    <div class="home">
        <div class="user-container">
            <div class="before-box"></div>
            <div class="user-box acea-row row-middle">
                <img :src="ava" alt="ava" class="ava" v-if="isLogin">
                <img :src="defaultUserHead" alt="default-ava" class="ava" v-else>
                <div class="user-info" v-if="isLogin">
                    <div class="name">Hu Guiying</div>
                    <div class="info-box acea-row">
                        <div>180 **** 5678</div>
                        <div class="badge" @click="jumpPage('realNameOuth')">未认证</div>
                    </div>
                </div>
                <div class="user-info" v-else @click="jumpPage('bindingMobile')">
                    <div class="name">登录/注册</div>
                    <div class="info-box acea-row">
                        <div>请先登录..</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="menu-box acea-row row-between">
            <Menu :icon="item.icon" :name="item.name" class="menu-item" v-for="item in menu" :key="item.id"
                  v-on:jump="jumpPage(item.url)"/>
        </div>
        <Overlay :show="show" z-index="3">
            <div class="wrapper acea-row row-middle row-center" @click="show = !show">
                <div class="block" @click.stop>
                    <img src="" alt="QR-CODE">
                </div>
            </div>
        </Overlay>
    </div>
</template>

<script>
    import Menu from "../components/Menu";
    import {Overlay} from 'vant';

    const loadImg = name => require(`@/assets/images/${name}.png`)
    export default {
        name: 'Home',
        components: {
            Menu,
            Overlay
        },
        data() {
            return {
                isLogin: true,
                ava: loadImg('ava'),
                defaultUserHead: loadImg('default_user_head'),
                menu: [
                    {
                        id: 1,
                        icon: loadImg('menu_icon1_1'),
                        name: '抢单',
                        url: 'robOrder'
                    },
                    {
                        id: 2,
                        icon: loadImg('menu_icon2'),
                        name: '拍摄订单',
                        url: 'shootOrder'
                    },
                    {
                        id: 3,
                        icon: loadImg('menu_icon3'),
                        name: '二维码',
                        url: null
                    },
                    {
                        id: 4,
                        icon: loadImg('menu_icon4'),
                        name: '余额',
                        url: 'balance'
                    }
                ],
                show: false
            }
        },
        methods: {
            jumpPage(page) {
                if (!page) {
                    this.show = true;
                } else {
                    this.$router.push(page)
                }
            }
        }
    }
</script>
<style scoped lang="scss">
    .home {
        position: relative;

        .user-container {
            height: 210px;
            background-color: #0DCDB5;

            .before-box {
                height: 38px;

            }

            .user-box {
                height: 110px;
                padding: 0 25px;

                .ava {
                    height: 78px;
                    width: 78px;
                    border-radius: 50%;
                    margin-right: 20px;
                    display: block;
                }

                .user-info {
                    color: #ffffff;

                    .name {
                        font-size: 32px;
                        font-weight: 500;
                    }

                    .info-box {
                        font-size: 16px;
                        font-weight: 400;
                        margin-top: 10px;

                        .badge {
                            display: inline-block;
                            border-radius: 4px;
                            background-color: #FF8D51;
                            padding: 2px 5px;
                            font-size: 12px;
                            margin-left: 10px;
                        }
                    }
                }
            }
        }

        .menu-box {
            position: absolute;
            top: 178px;
            z-index: 2;
            width: 100%;
            padding: 0 15px;

            .menu-item:nth-child(3) {
                margin-top: 15px;
            }

            .menu-item:nth-child(4) {
                margin-top: 15px;
            }
        }
        .wrapper{
            height: 100%;
            .block{
                width:280px;
                height:300px;
                background:rgba(255,255,255,1);
                border-radius:11px;
            }
        }
    }

</style>
